package com.ziyun.erp.modules.freightages.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import com.ziyun.erp.modules.freightages.dao.FreightAreaDao;
import com.ziyun.erp.modules.freightages.entity.FreightAreaEntity;
import com.ziyun.erp.modules.freightages.service.FreightAreaService;


@Service("freightAreaService")
public class FreightAreaServiceImpl extends ServiceImpl<FreightAreaDao, FreightAreaEntity> implements FreightAreaService {

    @Autowired
    private FreightAreaDao freightAreaDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String templateId = (String) params.get("templateId");
        Page<FreightAreaEntity> page = this.selectPage(
                new Query<FreightAreaEntity>(params).getPage(),
                new EntityWrapper<FreightAreaEntity>()
                        .eq(StringUtils.isNotBlank(templateId), "template_id", templateId)
        );
//        List<FreightAreaEntity> freightAreaEntityList = this.selectByMap(params);
        return new PageUtils(page);
    }

    /**
     * 标记删除地区运费模板
     *
     * @param freightAreaIds
     */
    @Override
    public void fagDeleteFreightAreas(ArrayList<Integer> freightAreaIds) {
        freightAreaDao.fagDeleteFreightAreas(freightAreaIds);
    }

    @Override
    public Integer getRegionId(String city, String city1) {
        return freightAreaDao.getRegionId(city,city1);
    }


}
